<?php
declare (strict_types=1);

namespace app\api\controller\v4;

use app\common\models\Datum;

class WordSpell extends BaseController
{
    /**
     * 获取单词拼写内容
     *
     * @return \think\Response
     */
    public function index()
    {
        $datum_cate_id = input('datum_cate_id/d',0);
        $page = input('page/d', 1);
        $model = new Datum();
        $rows = $model->where(['datum_cate_id' => $datum_cate_id, 'status' => 1])->count();
        if ($page > $rows)
            return errMsg(400, '没有更多数据...');
        $data = $model->where(['datum_cate_id' => $datum_cate_id, 'status' => 1])
            ->field('id,datum_cate_id,title,desc,example,translate,else')
            ->page($page, 1)
            ->select();
        return sucessMsg(200,'获取成功',['data' => $data, 'total' => $rows, 'maxPage' => $rows]);
    }
}